<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>需整改</title>
    <link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <style>
        body {}
    </style>
</head>

<body>
    <ul class="aui-list aui-media-list" id="matlist">
    </ul>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/doT.min.js"></script>
<script type="text/template" id="template">
    {{~it:value:index}}
    <li class="aui-list-item aui-list-item-arrow" onclick="checkdetail('{{=value.id}}')">
        <div class="aui-media-list-item-inner">
            <div class="aui-list-item-inner">
              <div class="aui-list-item-text">
                  <div class="aui-list-item-title">{{=value.project_name}}</div>
                  <div class="aui-list-item-right">{{=value.add_time}}</div>
              </div>
              <div class="aui-list-item-text aui-ellipsis-2">
                楼栋：{{=value.build}}&nbsp;楼层：{{=value.floor}}
              </div>
            </div>
        </div>
    </li>
    {{~}}
</script>
<script type="text/javascript">
    var token = $api.getStorage('token');
    var uid = $api.getStorage('uid');
    apiready = function() {
        init()
    };
    var init = function() {
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '先喝杯茶...',
            modal: false
        });

        api.ajax({
            url: $api.SERVE_URL + 'index.php/index/Quality/qualityList',
            method: 'post',
            dataType: "json",
            headers: {
                'token': token
            },
            data: {
                values: {
                    'cate_type': 2,
                    'limit': 20,
                    'page': 1,
                    'pid': "",
                    'token_uid': uid
                }
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.code === 200) {
                    api.hideProgress();
                    var data = ret.data.list;
                    var tempTxt = doT.template($api.byId('template').innerHTML);
                    $api.byId('matlist').innerHTML = tempTxt(data);
                } else if (ret.code === 401) {
                    api.toast({
                        msg: ret.msg,
                        duration: 2000,
                        location: 'top'
                    });
                    setTimeout(function() {
                        api.closeToWin({
                            name: 'root'
                        });
                        api.closeFrameGroup({
                            name: 'matframegroup'
                        });
                    }, 2000)
                }
                // console.log(JSON.stringify(ret));
            } else {
                // console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 2000,
                    location: 'top'
                });

            }
        });
    }

    var checkdetail = function (id) {
      api.openWin({
          name: 'safedetail',
          url: '../detail/safedetail.html',
          pageParam: {
              id: id
          }
      });

    }
</script>

</html>
